package com.example.module_word.room;

import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.Query;

import com.example.module_word.room.entity.JiHua;
import com.example.module_word.room.entity.MyStack;
import com.example.module_word.room.entity.MyWord;

import java.util.List;

@Dao
public interface DanCiDao {

    //aiciba  原始表

    //查询单词种类
    @Query("SELECT DISTINCT kind FROM aiciba")
    List<String> queryWorkKind();
    //查询该种类单词的数量
    @Query("SELECT COUNT(*) FROM aiciba WHERE kind = :kind")
    long queryCountByKind(String kind);
    //查询该种类的单词
    @Query("SELECT * FROM aiciba WHERE kind = :kind")
    List<Danci> queryDanCiByKind(String kind);

    //新建表 MyStack，用来保存我的书库

    //保存到我的书库
    @Insert
    void insertMyStack(MyStack...myStacks);
    //查询我的书库是否以经存在该kind
    @Query("select kind from MyStack where kind=:kind")
    List<String> queryMyStackByKind(String kind);
    //查询我的书库
    @Query("select DISTINCT kind from MyStack")
    List<String> queryMyStack();
    //根据kind删除MyStack中的值
    @Query("delete from MyStack where kind=:kind")
    void deleteMyStackByKind(String kind);
    //查询被选中的
    @Query("select kind from MyStack where flag=:flag")
    String queryMyStackByFlag(boolean flag);
    //修改是否被选中
    @Query("update MyStack set flag=:flag where kind=:kind")
    void updateMyStackByKind(boolean flag,String kind);

    //新建表   用来保存计划

    //添加计划
    @Insert
    void insertJiHua(JiHua...jiHuas);
    @Insert
    void insertJiHua(List<JiHua> list);
    //查询
    @Query("select * from jihua where kind=:kind")
    List<JiHua> queryJiHuaByKind(String kind);

    //查询被选中的
    @Query("select kind from jihua where isSelect=:isSelect")
    String queryJiHuaByIsSelect(boolean isSelect);
    //修改开始时间和结束时间
    @Query("update JiHua set start_time=:start_time,end_time=:end_time where kind=:kind")
    void updateJiHua(Long start_time,Long end_time,String kind);
    //修改签到次数
    @Query("update JiHua set day=:day where kind=:kind")
    void updateJiHuaDayByKind(int day,String kind);

    //新建表  用来保存已经学过的单词
    @Insert
    void insertMyWord(MyWord...myWords);
    //查询该单词是否已经存在
    @Query("select * from MyWord where word=:word")
    List<MyWord> queryMyWordByWord(String word);
    //查询已学过单词
    @Query("select * from MyWord")
    List<MyWord> queryMyWord();
    //查询该单词是否已经存在
    @Query("select count(*) from MyWord where kind=:kind")
    int queryMyWordCountByKind(String kind);
}
